<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            font-family: Arial, Helvetica, sans-serif;
        }
    </style>
</head>

<body>


    <h1>ajax ajax : 通过 Ajax 访问后台数据 </h1>

    <button style="padding: 12px;font-size: 23px;" onclick="get_data()">click me </button>

    <h1 id="result"></h1>


    <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.1.1/jquery.min.js"
        type="application/javascript"></script>
    <script>

        function get_data(params) {
            var name = "威廉";
            var address = "西雅图";
            $.ajax({
                type: "POST",
                url: "/find_by_address/",
                data: { "name": name, "address": address },
                datatype: "json",
                success: function (ret) {
                    $('#result').text(ret.address)
                },
                //调用出错执行的函数
                error: function () {
                    //请求出错处理
                }
            })
        }
        $(document).ready(function () {

        });
    </script>

</body>

</html>